import pandas as pd

def count_starbucks_stores():
    try:
        # 读取数据
        df = pd.read_csv('directory.csv')
        
        # 处理输入
        query = input().strip().split()
        query_type = int(query[0])
        query_content = ' '.join(query[1:])
        
        # 根据查询类型筛选数据
        if query_type == 1:
            # 按国家或地区查询
            result = df[df['Country'] == query_content]
        elif query_type == 2:
            # 按城市查询
            result = df[df['City'] == query_content]
        else:
            print("无效的查询类型")
            return
        
        # 输出结果
        print(len(result))

    except FileNotFoundError:
        print("错误：未找到文件 'directory.csv'")
    except Exception as e:
        print(f"发生错误：{e}")
    
count_starbucks_stores()